//***************************************************************************************

//              利用霍夫圆变换实现圆弧检测-canny高阈值为200，圆心累加阈值为110

//***************************************************************************************

#include "ImageDecMat.hpp"

void ImageDecMat::on_arcDetector(cv::Mat Image1,cv::Mat& Image2)
{
    int highThresh=200;
    int spotThresh=110;
    //进行高斯平滑
    GaussianBlur(Image1, Image1, cv::Size(5,5), 2,2);
    //进行霍夫圆变换
    std::vector<cv::Vec3f> Circles;
    HoughCircles(Image1, Circles, CV_HOUGH_GRADIENT, 1.5, 15,highThresh,spotThresh,0,0);//canny高阈值为200，圆心累加阈值为110
    //循环遍历绘制圆
    for(size_t i=0;i<Circles.size();++i)
    {
        cv::Point center(cvRound(Circles[i][0]),cvRound(Circles[i][1]));
        int radius=cvRound(Circles[i][2]);
        //绘制圆心
        circle(Image1, center, 3, cv::Scalar(0,255,0),-1,8,0);
        //绘制圆轮廓
        circle(Image1, center, radius, cv::Scalar(155,50,255),3,8,0);
    }
    Image1.copyTo(Image2);
    
}
